package com.yzmoney.common.web.springmvc;

import com.yzmoney.common.util.JDKStackTrace;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by LiuJun on 2015/7/29.
 */
public class ExHandlerExceptionResolver implements HandlerExceptionResolver {
    private static Log log = LogFactory.getLog(ExHandlerExceptionResolver.class);

    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception ex) {
        log.warn(JDKStackTrace.getJDKStrack(ex));
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("redirect:/");
        return modelAndView;
    }
}
